package com.platform.qujia.dao;

import com.platform.qujia.pojo.*;
import com.platform.qujia.pojo.dto.DivideAccountsSettingDto;
import com.platform.qujia.pojo.dto.TransactionDTO;
import com.platform.qujia.pojo.vo.CouponUserCountVO;
import com.platform.qujia.pojo.vo.POSPayOrderVO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface PayOrderMapper {

    //POS查询小城现金支付订单
    List<PayOrder> posSelectAppCashPayOrdersList(PayOrder payOrder);

    PayOrder selectPosPayOrderInfoByOrderRandomId(String orderRandomId);

    int insertTransaction(TransactionDTO transaction);
    int updateTransactionStatus(TransactionDTO transaction);

    int deleteTransactionStatus(TransactionDTO transaction);


    List<PayOrder> selectPosPayOrderListInfoByOrderRandomId(String orderRandomId);

    //查询用户的在该油企订单数量
    int selectUserOrderCount(Map<String, Object> param);

    //LNG 平台第三方订单消费余额记录
    void insertStationBalanceExchange(StationBalanceChange stationBalanceChange);

    //根据订单号查询订单
    PayOrder selectOrderInfoByOrdNo(String orderNo);

    Integer selectPayWayByMno(String inMerAccNo);

    //根据uuid查询订单
    PayOrder selectOrderInfoByUuid(String uuid);


    void updateSxfUuid(TransactionDTO transaction);

    //根据手机号查询优惠券数量
    int selectOrderCouponCountByOrdNo(PayOrder payOrder);


    //根据优惠券no和手机号查月和日
    public CouponUserCountVO selectByCouponNoPhoneDay( @Param("mobilePhone") String mobilePhone, @Param("couponType") String couponType, @Param("couponAmt") BigDecimal couponAmt);

    public CouponUserCountVO selectByCouponNoPhoneByUserCouponId(@Param("couponUserId") String couponUserId, @Param("mobilePhone") String mobilePhone);

    //根据优惠券no和手机号几次
    public List<CouponUserCountVO> selectByCouponNoPhoneAllCount(@Param("couponNo") String couponNo, @Param("mobilePhone") String mobilePhone);

    //
    public CouponUserCountVO selectCounponActivityCount(Map<String, Object> objectMap);

    //
    public CouponUserCountVO selectCounponActivityMoonCount(Map<String, Object> objectMap);

    //根据优惠券no和手机号查月和日
    public CouponUserCountVO selectByCouponNoPhoneMoon(@Param("couponType") String couponType, @Param("couponAmt") BigDecimal couponAmt,@Param("mobilePhone") String mobilePhone,@Param("startDate") String startDate);

    public List<DivideAccountsSettingDto> selectDivideSettingDetail(@Param("beginMmo") String beginMmo,@Param("stationId") String stationId);

    //根据商户订单号查询订单
    PayOrder selectOrderInfoByMerchantsNumber(String merchantsNumber);

    //获取系统支付类型
    List<PayType> selectPayTypeList();

    //获取订单列表已转化汉字支付方式的
    List<PayOrder>  selectPayOrderListFormater(PayOrder payOrder);

    //查询POS机近七天数据
    List<Map<String, Object>> selectPosRecentlySevenData(PayOrder payOrder);

    //获取POS机昨天数据
    Map<String, Object> selectPosYesterDayData(PayOrder payOrder);

    //查询汇总数据
    List<Map> selectSum(PayOrder payOrder);

    Map<String, Object> selectSumTmp(PayOrder payOrder);

    /*
     * 根据用户openId和用户类型userType查询用户订单
     * @param payOrder
     * @return
     */
    List<PayOrder> getOrderListByOpenIdAndUserType(AppUserInfo appUserInfo);

    /*
     * 根据用户unionId查询用户订单
     * @return
     */
    List<PayOrder> getUserOrderListByUnionId(AppUserInfo appUserInfo);


    /*
     * 根据手机号查询用户订单
     * @param appUserInfo
     * @return
     */
    List<PayOrder> getUserOrderListByMobilePhone(AppUserInfo appUserInfo);

    /*
     *修改订单状态
     */
    int getUpdatePayOrder(PayOrder payOrder);


    int setMnoPayWayIdUpdatePayOrder(PayOrder payOrder);

    int getUpdatecouponUser(PayOrder payOrder);

    /*
     * 查询客户是否已存在
     * @param customerManage
     * @return
     */
    CustomerManage isExistCustomer(CustomerManage customerManage);

    /*
     * 根据用户登录openId 获取用户信息用于插入客户表
     * @param appUserInfo
     * @return
     */
    List<AppUserInfo> getUserInfoByOpenId(AppUserInfo appUserInfo);

    /*
     *  插入客户
     * @param customerManage
     * @return
     */
    void insertCustomer(CustomerManage customerManage);

    /*
     *  根据手机号更新客户表
     * @param customerManage
     */
    void updateCustomerByPhoneNumber(CustomerManage customerManage);

    /*
     *  生成订单时更新客户表
     * @param customerManage
     * @return
     */
    void updateCustomer(CustomerManage customerManage);

    /*
     * 根据订单号查询订单信息和用户信息  注：此方法在随行付回调校验之后修改状态完成后
     * @param payOrder
     * @return
     */
    Map<String, Object> getOrderInfoAndUserInfoByOrderNo(PayOrder payOrder);

    /***
     * 根据油品名称和油站查询油品调价信息
     * @param map
     * @return
     */
    List<Map> selectOilPriceAdjust(Map<String, Object> map);

    /***
     * 根据油品名称和油站查询油枪编号,油站名称,价格,加油员
     * @param map
     * @return
     */
    List<Map> selectOilGunNoAndOilPrice(Map<String, Object> map);

    //查询加油员
    List<Map> selectPersonelName(Map<String, Object> map);

    //查询班结订单
    List<PayOrder> selectPayOrderList(PayOrder payOrder);

    PayOrder getPayOrderInfoMin(PayOrder payOrder);


    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    long countByExample(PayOrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    int deleteByExample(PayOrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    int deleteByPrimaryKey(Integer orderId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    int insert(PayOrder record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    int insertSelective(PayOrder record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    List<PayOrder> selectByExample(PayOrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    PayOrder selectByPrimaryKey(Integer orderId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    int updateByExampleSelective(@Param("record") PayOrder record, @Param("example") PayOrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    int updateByExample(@Param("record") PayOrder record, @Param("example") PayOrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    int updateByPrimaryKeySelective(PayOrder record);



    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table pay_order
     *
     * @mbg.generated
     */
    int updateByPrimaryKey(PayOrder record);

    int delOldRandomId(String orderRandomId);

    List<POSPayOrderVO> selectPayOrderListTemp(PayOrder payOrder);

    Map<String,Object> selectServiceCharge(Integer stationId,Integer appType);
    
    /**
     * 新的添加订单
     */
    int insertSelectiveOrder(PayOrder record);
    
    /**
     * 更新订单支付时间
     * @param da
     * @return
     */
    int updateOrderPayDate(@Param("payDate")Date payDate,@Param("orderNo")String orderNo);
    
    //根据订单号查询订单
    public PayOrder selectByOrdNo(@Param("orderNo")String orderNo);
    
    /*
     *修改订单状态
     */
    int updatePayOrder(PayOrder payOrder);

    /**
     *  更新订单开发票状态
     * @return
     */
    int updateInvoiceStatus(@Param("orderNo")String orderNo,@Param("InvoiceStatus")Integer invoiceStatus);

    //查询临时订单表
    List<PayOrder> selectPayOrderListAll();

    //判断dzk重复支付
    int checkDzkRepeatPay(PayOrder payOrderInfo);


    PayOrder getOneBetweenCreatedDateAndCreateDesc(PayOrder payOrder);

    int updateGrowthValueByOrdNo(@Param("growthValue") Long growthValue,@Param("orderNo") String ordNo);

    /**
     * 根据手机号或userId获取一个订单id，判断是否有已支付过的订单
     * @param appUserInfo
     * @return
     */
    Integer getOneUserPaidOrderId(AppUserInfo appUserInfo);

    int updateInvoiceStatusByOrdNoAndBusinessName(@Param("orderNo") String orderNo,@Param("invoiceStatus") Integer invoiceStatus,@Param("businessName") String businessName);

    List<PayOrder> selectPayOrderListFormater2(PayOrder payOrder);

    List<PayOrder> selectPayOrderListFormater3(PayOrder payOrder);

    /**
     * 实体卡新增订单支付
     *
     * @param payOrder 订单支付
     * @return 结果
     */
    public int insertPayOrder(PayOrder payOrder);

    int updateOrderStatusByClientOrderNoAndClientSerialNo(CloudHuaSwipeCardCallbackOrder order);

    int updateOrderMergeNoByOrderNos(@Param("orderMergeNo")String orderMergeNo,@Param("orderNos")List<String> orderNos);


    int updatePayOrderReceivableAmt(PayOrder payOrder);

    /**
     * 更新议价金额
     *
     * @param payOrder 订单支付
     * @return 结果
     */
    int updateBargainAmt(PayOrder payOrder);

    PayOrder selectPayOrderByStatus(PayOrder payOrder);
}
